package ro.licenta.room.kitchen;

import ro.licenta.utilities.utils.StaticUtils;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.test.R;

public class FridgeAdapter extends BaseAdapter {

	private LayoutInflater mInflater;

	public FridgeAdapter(Context c) {
		mInflater = LayoutInflater.from(c);
	}

	public int getCount() {
		return StaticUtils.kitchenResourceId.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

	// create a new ImageView for each item referenced by the
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) { // if it's not recycled,
			convertView = mInflater.inflate(R.layout.categorycontent, null);
			convertView.setLayoutParams(new GridView.LayoutParams(90, 100));
			holder = new ViewHolder();
			holder.title = (TextView) convertView
					.findViewById(R.id.categoryText);
			holder.icon = (ImageView) convertView
					.findViewById(R.id.categoryimage);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.icon.setAdjustViewBounds(true);
		holder.icon.setScaleType(ImageView.ScaleType.CENTER_CROP);
		holder.icon.setPadding(8, 8, 8, 8);
		holder.title.setText(StaticUtils.kitchenResourceName[position]);
		holder.icon.setImageResource(StaticUtils.kitchenResourceId[position]);
		return convertView;
	}

	class ViewHolder {
		TextView title;
		ImageView icon;
	}

	// references to our images

}
